package com.svnservices;

import hannibal.servlet.rest.RestfulSecurityContext;

@javax.annotation.Generated
(
	value="hannibal.generator.Generator",
	comments="",
	date = ""
)

public class AppProfile
   implements hannibal.AppProfile
{
	private static final java.util.Collection <String> collection = new java.util.ArrayList<String>();
	private static final java.util.Map<String, String> map = new java.util.HashMap<String, String>();
	private static final java.util.Map<String, String> domainToClassMap = new java.util.HashMap<String, String>();
	private static final java.util.Map<String, String> domainToShortClassMap = new java.util.HashMap<String, String>();
	private static final hannibal.servlet.rest.RestfulSecurityContext securityContext = new hannibal.servlet.rest.RestfulSecurityContext();

	static
	{
		//Domains
		collection.add("svnmessage");
		collection.add("svnerror");
		collection.add("svninfo");
		collection.add("user");
		collection.add("svnrepository");
		collection.add("svnauthorization");

		//Domain to class map
		domainToShortClassMap.put("svnmessage", "SvnMessage");
		domainToShortClassMap.put("svnerror", "SvnError");
		domainToShortClassMap.put("svninfo", "SvnInfo");
		domainToShortClassMap.put("user", "User");
		domainToShortClassMap.put("svnrepository", "SvnRepository");
		domainToShortClassMap.put("svnauthorization", "SvnAuthorization");

		//Domain to class map
		domainToClassMap.put("svnmessage", "com.svnservices.hannibal.activerecord.SvnMessageAR");
		domainToClassMap.put("svnerror", "com.svnservices.hannibal.activerecord.SvnErrorAR");
		domainToClassMap.put("svninfo", "com.svnservices.hannibal.activerecord.SvnInfoAR");
		domainToClassMap.put("user", "com.svnservices.hannibal.activerecord.UserAR");
		domainToClassMap.put("svnrepository", "com.svnservices.hannibal.activerecord.SvnRepositoryAR");
		domainToClassMap.put("svnauthorization", "com.svnservices.hannibal.activerecord.SvnAuthorizationAR");

		//Domain attribute types
		map.put("svnmessage.message", "java.lang.String");
		map.put("svnmessage.id", "java.lang.String");
		map.put("svnmessage.category", "java.lang.String");
		map.put("svnmessage.name", "java.lang.String");
		map.put("svnerror.message", "java.lang.String");
		map.put("svnerror.id", "java.lang.String");
		map.put("svnerror.category", "java.lang.String");
		map.put("svnerror.name", "java.lang.String");
		map.put("svninfo.message", "java.lang.String");
		map.put("svninfo.revision", "java.lang.String");
		map.put("svninfo.author", "java.lang.String");
		map.put("svninfo.name", "java.lang.String");
		map.put("svninfo.date", "java.lang.String");
		map.put("user.id", "java.lang.String");
		map.put("user.name", "java.lang.String");
		map.put("user.password", "java.lang.String");
		map.put("svnrepository.revision", "java.lang.String");
		map.put("svnrepository.lastAuthor", "java.lang.String");
		map.put("svnrepository.status", "java.lang.String");
		map.put("svnrepository.root", "java.lang.String");
		map.put("svnrepository.name", "java.lang.String");
		map.put("svnrepository.lastModifiedDate", "java.lang.String");
		map.put("svnrepository.URL", "java.lang.String");
		map.put("svnauthorization.id", "java.lang.String");
		map.put("svnauthorization.permission", "java.lang.String");
		map.put("svnauthorization.repositoryName", "java.lang.String");
		map.put("svnauthorization.user", "java.lang.String");

		//Restful security context
	}

	public AppProfile() {}

	public String getAppName()
	{
		return "svnservices";
	}

	public String getRootPackageName()
	{
		return "com.svnservices";
	}

	public String getDomainShortClassName(String _domainName)
	{
		return domainToShortClassMap.get(_domainName.toLowerCase());
	}

	public String getFullyQualifiedARClassName(String _domainName)
	{
		return domainToClassMap.get(_domainName.toLowerCase());
	}

	public hannibal.domain.ActiveRecord createActiveRecord(String _domainName)
	{
		hannibal.domain.ActiveRecord activeRecord = null;
		
		try
		{
			activeRecord =  (hannibal.domain.ActiveRecord) Class.forName(getFullyQualifiedARClassName(_domainName)).newInstance();
		}
		catch(Throwable t)
		{
			throw new hannibal.HannibalException("Unable to create active record for domain: " + _domainName, t);
		}

		return activeRecord;
	}

	public java.util.Collection getValidDomains()
	{
		return new java.util.ArrayList<String>(collection);
	}

	public boolean isValidDomain(String _domainName)
	{
		return collection.contains(_domainName.toLowerCase());
	}

	public String getAttributeType(String _domainName, String _attributeName)
	{
		return map.get(_domainName.toLowerCase() + "." + _attributeName);
	}

	public boolean hasAttribute(String _domainName, String _attributeName)
	{
		return map.containsKey(_domainName.toLowerCase() + "." + _attributeName);
	}

	public hannibal.SecurityContext getSecurityContext()
	{
		return this.securityContext;
	}
}